package com.peanut.bosskg.controller;

import com.alibaba.fastjson.JSON;
import com.peanut.bosskg.entity.ResponseMessageVO;
import com.peanut.bosskg.service.BaseService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @ClassName: NotifyController
 * @Description: 通知信息（两分钟一次共5次）
 * @Author: chc
 * @Date: 2022/7/5
 **/
@Controller
@RequestMapping("/notify")
@Slf4j
public class NotifyController {

    @Autowired
    BaseService baseService;

    @PostMapping(value = "/doBusiness")
    @ResponseBody
    public String doBusiness(@RequestBody String encryptedMsg) {

        log.info("BOSSKG异步通知返回报文:" + encryptedMsg);
        ResponseMessageVO encryptedResponseMessage = JSON.parseObject(encryptedMsg, ResponseMessageVO.class);
        ResponseMessageVO responseMessageVO = baseService.handleResponse(encryptedResponseMessage);
        String notifyData = responseMessageVO.getResData();
        log.info("BOSSKG异步通知返回结果-notifyData:" + notifyData);
        //返回给bosskg的结果
        return "SUCCESS";
    }
}
